﻿@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True *@
@using System
@using System.Linq
@using Hangfire.Common
@using Hangfire.Dashboard
@using Hangfire.Dashboard.Pages
@using Hangfire.Dashboard.Resources
@inherits RazorPage
@{
    Layout = new LayoutPage(Strings.ServersPage_Title);
    
    var monitor = Storage.GetMonitoringApi();
    var servers = monitor.Servers();
}

<div class="row">
    <div class="col-md-12">
        <h1 class="page-header">@Strings.ServersPage_Title</h1>

        @if (servers.Count == 0)
        {
            <div class="alert alert-warning">
                @Strings.ServersPage_NoServers
            </div>
        }
        else
        {
            <div class="table-responsive">
                <table class="table">
                    <thead>
                        <tr>
                            <th>@Strings.ServersPage_Table_Name</th>
                            <th>@Strings.ServersPage_Table_Workers</th>
                            <th>@Strings.ServersPage_Table_Queues</th>
                            <th>@Strings.ServersPage_Table_Started</th>
                            <th>@Strings.ServersPage_Table_Heartbeat</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var server in servers)
                        {
                            <tr>
                                <td>@Html.ServerId(server.Name)</td>
                                <td>@server.WorkersCount</td>
                                <td>@Html.Raw(String.Join(", ", server.Queues.Select(Html.QueueLabel)))</td>
                                <td>@Html.RelativeTime(server.StartedAt)</td>
                                <td>
                                    @if (server.Heartbeat.HasValue)
                                    {
                                        @Html.RelativeTime(server.Heartbeat.Value)
                                    }
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
        }
    </div>
</div>